

/*
* Copyright @ 2017 com.iflysse.trains
* crm 下午4:12:50
* All right reserved.
*
*/
	
package com.qf.service.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import com.qf.dao.CrmDepartmentDao;
import com.qf.dto.CrmDepartmentDto;
import com.qf.pojo.CrmDepartment;
import com.qf.pojo.PageBean;
import com.qf.service.CrmDepartmentService;

/**
* @desc: crm
* @descripe:XXXX
* @author: 周锐
* @createTime: 2017年7月24日 下午4:12:50
* @history:
* @version: v1.0

*/

public class CrmDepartmentServiceImpl implements CrmDepartmentService {
     private CrmDepartmentDao cd;
     
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#addDepartment(com.qf.pojo.CrmDepartment)
	*/

	
	/**
	* @param cd the cd to set
	*/
	
	public void setCd(CrmDepartmentDao cd) {
	
		this.cd = cd;
	}

	@Override
	public void addDepartment(CrmDepartment department) {
         
		 cd.addDepartment(department);
	}

	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#updateDepartment(com.qf.pojo.CrmDepartment)
	*/

	@Override
	public void updateDepartment(CrmDepartment department) {
		cd.updateDepartment(department);
		

	}

	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#findbyID(java.lang.Long)
	*/

	@Override
	public CrmDepartment findbyID(Long depId) {

		return cd.findbyID(depId);
		

	}

	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#findAllDepartment()
	*/

	@Override
	public List<CrmDepartmentDto> findAllDepartment() {

		//TODO
		List<CrmDepartment> list = cd.findAllDepartment();
		List<CrmDepartmentDto> departmentDtos=new ArrayList<>();
		for(CrmDepartment department:list){
			CrmDepartmentDto cd=new CrmDepartmentDto();
			cd.setDepId(department.getDepId());
			cd.setDepName(department.getDepName());
			departmentDtos.add(cd);
		}
         return departmentDtos;
	}

	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#findDepartmentByPage(int, int)
	*/
		
	@Override
	public PageBean findDepartmentByPage(int page, int size) {
		
		//TODO
		return cd.findDepartmentByPage(page, size);
			
	}

	
	/*
	*(non-Javadoc)
	* @see com.qf.service.CrmDepartmentService#findByName(java.lang.String)
	*/
		
	@Override
	public CrmDepartment findByName(String name) {
		
		//TODO
		return cd.findByName(name);
			
	}

}

	